<h4>Add Track by Upload</h4>
<form id="add-track-by-upload">

    <input type="file" id="add-track-by-upload-file" />
    
    <p style="float: right;">
        <input type="submit"
               value="Upload Tracks" />
    </p>
    <div class="clear" ></div>
</form>

<script type="text/javascript">
    var av_current_count;
    var html5av_uploadifyLoc = '<?php echo html5av_manager::getUrl(); ?>/lib/uploadify';
    var html5av_api = '<?php echo html5av_manager::getApiURL() ?>';
    
    jQuery(function($) {
        $('#add-track-by-upload-file').html5avUploadify({
            'uploader'  : html5av_uploadifyLoc+'/uploadify.swf',
            'script'    : html5av_uploadifyLoc+'/custom.php',
            'cancelImg' : html5av_uploadifyLoc+'/cancel.png',
            'folder'    : '/temp',
            'removeCompleted' : true,
            'multi'     : true,
            'onComplete': function(event, ID, fileObj, response, data) {
                var json = $.parseJSON(response);
                var post = {
                    action: 'html5av_manager',
                    node:'track_upload_submit',
                    path:json.path,
                    file:json.file,
                    count:av_current_count,
                    avid:av_edit_id
                }
                $.post(ajaxurl, post);
                av_current_count++;
            },
            'onAllComplete': function(event,data) {
                window.setTimeout(function() {
                    html5avReset();
                }, 3000)
            },
            'simUploadLimit':1,
            'fileDesc':'Select Track Files',
            'buttonText':'Select Track Files'
        });
        
        $('#add-track-by-upload').submit(function() {
            var post = {
                action: 'html5av_manager',
                node:'track_count',
                avid:av_edit_id
            };
            $.post(ajaxurl, post, function(json) {
                json = $.parseJSON(json);
                av_current_count = json.count;
                av_current_count++;
                $('#add-track-by-upload-file').html5avUploadifyUpload();
            });
            return false;
        });
    });
</script>